/** Part of Zombie Navigator
	Copyright © 2016  Zombie Navigator Developers
	
	@file
	@module
	@license AGPL-3.0+
	
*/ 'use strict';


/* Addon SDK dependencies */
const _sdkSelf = require('sdk/self');
const _sdkSystem = require('sdk/system');


/* Private properties */

/** @private */
const PACKAGE_JSON = require('../../package.json');


/* Internal APIs */

/**
	In lower case
	@public
	@method
	@returns {string}
*/
const getSystemName = () => {
	const sdkSystem = _sdkSystem;
	
	return sdkSystem.platform + '';
};

/**
	In lower case
	@public
	@method
	@returns {string}
*/
const getSystemArchitecture = () => {
	const sdkSystem = _sdkSystem;
	
	return sdkSystem.architecture + '';
};

/**
	@public
	@method
	@returns {string}
*/
const getSystemDescription = () => {
	const systemName = getSystemName();
	
	let description;
	switch (systemName) {
		case 'linux': description = 'GNU/Linux'; break;
		case 'darwin': description = 'Darwin (Apple OS/X)'; break;
		case 'winnt': description = 'Microsoft Windows'; break;
		default: description = platformName;
	}
	
	let arch = getSystemArchitecture();
	
	return `${description} (${arch})`;
};

/**
	@public
	@method
	@returns {string}
*/
const getPlatformName = () => {
	const sdkSystem = _sdkSystem;
	
	return sdkSystem.name + '';
};

/**
	@public
	@method
	@returns {string}
*/
const getPlatformVersion = () => {
	const sdkSystem = _sdkSystem;
	
	return sdkSystem.version + '';
};

/**
	@public
	@method
	@returns {string}
*/
const getProductName = () => (PACKAGE_JSON.title + '');

/**
	@public
	@method
	@returns {string}
*/
const getProductShortName = () => (PACKAGE_JSON.name + '');

/**
	@public
	@method
	@returns {string}
*/
const getProductID = () => {
	const sdkSelf = _sdkSelf;
	
	return sdkSelf.id + '';
};

/**
	@public
	@method
	@returns {string}
*/
const getProductVersion = () => {
	const sdkSelf = _sdkSelf;
	
	return sdkSelf.version + '';
};

/**
	@public
	@method
	@param {string} path
	@returns {string}
*/
const getURIFromDataPath = path => {
	const sdkSelf = _sdkSelf;
	
	return sdkSelf.data.url(path + '') + '';
};

/**
	@public
	@method
	@returns {string}
	XXX: want to avoid the hardcoded value?
*/
const getLicenseURI = () => {
	return getURIFromDataPath('../LICENSE');
};


/* Exports */
exports.getSystemName = getSystemName;
exports.getSystemArchitecture = getSystemArchitecture;
exports.getSystemDescription = getSystemDescription;
exports.getPlatformName = getPlatformName;
exports.getPlatformVersion = getPlatformVersion;
exports.getProductName = getProductName;
exports.getProductShortName = getProductShortName;
exports.getProductID = getProductID;
exports.getProductVersion = getProductVersion;
exports.getURIFromDataPath = getURIFromDataPath;
exports.getLicenseURI = getLicenseURI;


// vim: ts=4 noet ai

